IF EXISTS (SELECT * FROM sysobjects WHERE name = 'GetParameterCdExistsBySrvrInstncIdMultiId' AND type IN ('FN','IF','TF'))
     DROP FUNCTION dbo.GetParameterCdExistsBySrvrInstncIdMultiId
GO

CREATE FUNCTION dbo.GetParameterCdExistsBySrvrInstncIdMultiId
     ( @SrvrInstncId     int,
       @ParameterMultiId int,
       @ParameterCd      varchar(30) )
RETURNS tinyint
AS
/*
 *
 * GetParameterCdExistsBySrvrInstncIdMultiId
 *
 * Purpose:      
 *
 * Inputs:       
 *
 * Assumes:      
 *
 * Effects:      Database is not affected.
 *
 * Returns:      Effective boolean representing whether the parameter exists.
 *
 * Note(s):      
 *
 * Author(s):    NOVA Concepts Ltd.
 *
 * Change Log:   Initial Release, 10/31/2011, 1.00.0000
 *
 */
BEGIN
     DECLARE @ReturnValue tinyint

     IF EXISTS ( SELECT 'X'
                 FROM   dbo.SrvrInstncEAV sie INNER JOIN dbo.Parameter p
                           ON sie.ParameterId      = p.ParameterId 
                          AND sie.SrvrInstncId     = @SrvrInstncId
                          AND sie.ParameterMultiId = @ParameterMultiId
                          AND p.ParameterCd         = @ParameterCd )
     BEGIN
          SET @ReturnValue = 1
     END
     ELSE
     BEGIN
          SET @ReturnValue = 0
     END
                         
     RETURN @ReturnValue
END
GO
